package com.liyasong.cf.movie;

import java.io.File;
import java.io.IOException;
import java.util.List;

import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.impl.model.file.FileDataModel;
import org.apache.mahout.cf.taste.impl.recommender.CachingRecommender;
import org.apache.mahout.cf.taste.impl.recommender.slopeone.SlopeOneRecommender;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.recommender.RecommendedItem;
import org.apache.mahout.cf.taste.recommender.Recommender;

public class MySlopeOneRecommender {

	private final Recommender recommender;
	
	public MySlopeOneRecommender() throws IOException, TasteException {
		DataModel dataModel = new FileDataModel(new File("ratings.dat"));
		recommender = new CachingRecommender(new SlopeOneRecommender(dataModel));
	}
	
	public static void main(String[] args) throws IOException, TasteException {
		MySlopeOneRecommender so = new MySlopeOneRecommender();
		List<RecommendedItem> recommendation = so.recommender.recommend(1024, 8);
		System.out.println(recommendation);
	}

}
